/*  
 *  Copyright 2006 Paul Jack.
 *
 *  This file is part of the Dex compiler suite. 
 *  
 *  Dex is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the
 *  Free Software Foundation; either version 2 of the License, or (at your
 *  option) any later version.
 *  
 *  Dex is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 *  Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */
package dex.compiler.model.expression;

import dex.compiler.model.base.Place;
import dex.compiler.model.type.TypeNode;


/**
 * An expression that deals with type conversion.
 * Base class for casts and instance tests.
 */
public abstract class ConvertExpression extends Expression {

	
	/**
	 * The type to cast the expression to.
	 */
	private TypeNode type;
	
	
	/**
	 * The value to cast.
	 */
	private Expression value;


	/**
	 * Constructs a new convert expression.
	 * 
	 * @param place  the place where the convert originated
	 * @param type   the type to convert the value to
	 * @param value  the value to convert
	 */
	public ConvertExpression(Place place, TypeNode type, Expression value) {
		super(place);
		if (value == null) {
			throw new IllegalArgumentException("value may not be null");
		}
		if (type == null) {
			throw new IllegalArgumentException("type may not be null");
		}
		this.value = value;
		this.type = type;
	}


	/**
	 * Returns the value to cast.
	 * 
	 * @return  the value to cast
	 */
	public Expression getValue() {
		return value;
	}

	
	/**
	 * Returns the type to cast the value to.
	 * 
	 * @return  the type to cast the value to
	 */
	public TypeNode getType() {
		return type;
	}

}
